﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Runtime.Serialization;

namespace Public
{
    [DataContract]
    public class Result
    {
        /// <summary>
        /// Used when operation is failed.
        /// </summary>
        /// <param name="exceptionMessage"></param>
        /// <param name="innerException"></param>
        public Result(string exceptionMessage, Exception innerException)
        {
            this.content = exceptionMessage;
            this.exceptions = new List<Exception>();
            this.exceptions.Add(innerException);
            this.isSuccessful = false;
        }

        /// <summary>
        /// Used when operation has been finished successfully.
        /// </summary>
        public Result(string content)
        {
            this.isSuccessful = true;
            this.content = content;
        }

        public Result(string exceptionMessage, List<Exception> exceptions)
        {
            this.isSuccessful = false;
            this.content = exceptionMessage;
            this.exceptions = exceptions;
        }

        [DataMember]
        private List<Exception> exceptions;

        [DataMember]
        private bool isSuccessful;

        [DataMember]
        private string content;

        public List<Exception> Exceptions { get { return exceptions; } }
        public bool IsSuccessful { get { return isSuccessful; } }
        public string Content { get { return content; } }
    }

}
